#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        sort(nums1.begin(),nums1.end());
        sort(nums2.begin(),nums2.end());
        int first=0,second=0;
        vector<int>ans;
        while(first<nums1.size()&&second<nums2.size())
        {

            while(first<nums1.size()&&nums1[first]<nums2[second])first++;
            while(second<nums2.size()&&nums1[first]>nums2[second])second++;
            if(first<nums1.size()&&second<nums2.size()&&nums1[first]==nums2[second])
            {
                if(ans.empty()||nums1[first]!=ans.back())
                    ans.push_back(nums1[first]);
                first++;
                second++;
            }
            
        }
        return ans;
    }
};
int main()
{
    class Solution s1;
    vector<int>nums1({1,2});
    vector<int>nums2({1,1});
    s1.intersection(nums1,nums2);
}